﻿var trunPageObj;//翻页组件对像
$(initPage);
function initPage() {
	//初始化翻页组件
    trunPageObj =  $(".pageNext").turnPage(12);
    
	$("#queryLog").click(function() {
		$("#log_list").empty();
		trunPageObj.gotoPage(1);//搜索第一页
	});
	trunPageObj.gotoPage(1);//搜索第一页
}

function queryList() {
	var beginDataDate = $("#beginDataDate").val();
	var endDataDate = $("#endDataDate").val();
	if ($.compareDate(beginDataDate, endDataDate)) {
		alert("开始日期不能大于结束日期");
		return;
	}
	var pageno=trunPageObj.getCurrentPageNo();//当前第几页
	var pagecount=trunPageObj.getPageCount();//一页多少条
	$.post("m/submit_log/query", {
		pageNo: pageno,
		pageSize : pagecount,
		beginDataDate:beginDataDate,
		endDataDate:endDataDate
	}, function(data) {
		if ($.checkErrorMsg(data) ) {
//				alert("系统提示：查询成功！");
			var fileList = "";
			if(data.submitLogPage && data.submitLogPage.dataList){
				var dataList = data.submitLogPage.dataList;
				$(dataList).each(function(i) {
					fileList += "<tr class='table_td_font' bgColor='#ffffff'>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + (i + 1) + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].formatDataDate + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].submitFiles.length + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].interfaceVersion + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].internalVersion + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" +  (dataList[i].increment ? "增量" : "全量") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" +  (dataList[i].resubmitted ? "是（Y）" : "否（N）") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].operateTime + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].operatorName + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap><a href='javascript:viewData(\"" + dataList[i].id + "\")'>查看</a></td>";
					fileList += "</tr>";
				});
			}
			$("#log_list").html(fileList);
			trunPageObj.setPageData(data.submitLogPage);
		} 
	}, "json");
}

//function selectTR(obj) {
//	$(obj).attr("bgColor","#FAEBD7").siblings().attr("bgColor","#FFFFFF");
//}

function viewData(id) {
	window.showModalDialog(BASE_PATH + "m/submit_log/view?logId=" + id,"","dialogWidth:720px;dialogHeight:620px;help:no;center:yes;status:no");
}